package com.zhl.spring.user.dao.impl;

import com.zhl.spring.user.dao.UserDao;
import com.zhl.spring.user.entity.User;
import org.springframework.jdbc.core.JdbcTemplate;
import sun.text.normalizer.IntTrie;

/**
 * @author zhl
 * @date 2021/1/20 18:28
 */
public class UserDaoImpl implements UserDao {

    private JdbcTemplate jdbcTemplate;

    public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }

    public int save(User user) {
        String sql = "insert into user2 values(?,?,?)";
        return jdbcTemplate.update(sql, user.getId(), user.getName(), user.getAge());
    }

    public int delete(int id) {
        String sql = "delete from user2 where id  = ?";
        return jdbcTemplate.update(sql, id);
    }


}
